<%@ page import="java.time.LocalDateTime" %>
<%@ page import="java.time.DayOfWeek" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 9/15
  Time: 15:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <%
        String[] weeks = {"星期一","星期二","星期三","星期四","星期五","星期六","星期天"};
        DayOfWeek dayOfWeek = LocalDateTime.now().getDayOfWeek();
        int index = dayOfWeek.getValue() - 1;//1:星期一 ，7：星期天

        String week = weeks[index];

        String[] strs = {"剪刀", "石头", "布"};
        int z = (int)(Math.random() * strs.length); //生成0-2的随机数
        int l = (int)(Math.random() * strs.length); //生成0-2的随机数

        String result;
        if (z == l) {
            result = "平局";
        } else if (z == 0 && l == 2 || z == 1 && l == 0 || z == 2 && l == 1){
            result = "张三获胜";
        } else {
            result = "李四获胜";
        }
    %>

    <!--表达式，表达式返回的必须是一个值-->
    <div>今天是：<%=week%></div>

    <h2>猜拳游戏</h2>
    <div>张三VS李四</div>
    <div>张三出拳：<%=strs[z]%></div>
    <div>李四出拳：<%=strs[l]%></div>
    <div>对战信息：<%=result%></div>
</body>
</html>
